cmake_minimum_required(VERSION 3.16)
project(enet)

set(CMAKE_CXX_STANDARD 17)
include(dnep-config.cmake)
message("DNEP root directory: " ${DNEP_ROOT_DIR})
message("DNEP pipe directory: " ${DNEP_PIPE_DIR})
message("DNEP config path: " ${DNEP_CONFIG_PATH})

# control where the static and shared libraries are built so that on windows
# we don't need to tinker with the path to run the executable
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")


add_subdirectory(util)
add_subdirectory(err)
add_subdirectory(arp)
add_subdirectory(ipvx)
add_subdirectory(dev)
add_subdirectory(dnep)


if (CMAKE_HOST_WIN32)
    add_subdirectory(pil/win32)
else()
    add_subdirectory(pil/linux)
endif()

# find_package(Qt5 COMPONENTS Widgets REQUIRED)
#find_library(Iphlpapi Iphlpapi.lib REQUIRED)
list(APPEND EXTRA_LIBS
        util
        err
        dev
        arp
        pil
        ipvx
#        Qt5::Widgets
        )

list(APPEND EXTRA_INCLUDES
        "./inc"
        )

add_executable(enet main.cpp)
add_executable(dnep_s dnep_s.cpp)

add_dependencies(dev util)
add_dependencies(pil err)
add_dependencies(dev pil)
add_dependencies(arp dev)
add_dependencies(ipvx dev)

target_link_libraries(dev PUBLIC pthread util)
target_link_libraries(ipvx PUBLIC dev)
target_link_libraries(dnep PUBLIC pil)
target_link_libraries(enet PUBLIC ${EXTRA_LIBS})
target_link_libraries(dnep_s PUBLIC dnep)

add_dependencies(dnep_s enet)

target_include_directories(enet PUBLIC
        "${PROJECT_BINARY_DIR}"
        ${EXTRA_INCLUDES}
        )
target_include_directories(dnep_s PUBLIC
        ${EXTRA_INCLUDES}
        )
